# FROM dhub.kubesre.xyz/jenkins/jenkins:latest
# FROM jenkins/jenkins:2.346.2-lts
# FROM dhub.kubesre.xyz/library/ubuntu:20.04
FROM registry.cn-shenzhen.aliyuncs.com/gonsinrd/ubuntu:20.04

USER root

LABEL MAINTAINER="GONSIN"
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install
ENV TZ=Asia/Shanghai
ENV LANG C.UTF-8
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# RUN mv /etc/apt/sources.list /etc/apt/sources.list.bk
COPY sources.list /etc/apt/sources.list

RUN apt-get update
RUN apt-get install -y vim
RUN apt-get install -y wget
RUN apt-get install -y zip

## 安装java 11
RUN wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/11/jdk/x64/linux/OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz
RUN mkdir /root/jenkins -p
RUN tar zxvf OpenJDK11U-jdk_x64_linux_hotspot_11.0.24_8.tar.gz -C /root/jenkins
RUN mv /root/jenkins/jdk-11.0.24+8 /root/jenkins/jdk -f

## 安装java 17
RUN wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/x64/linux/OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz
RUN mkdir /root/jenkins -p
RUN tar zxvf OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz -C /root/jenkins
RUN mv /root/jenkins/jdk-17.0.12+7 /root/jenkins/jdk17 -f

## 安装java 8
RUN wget http://update.gonsincloud.com/jenkins/jdk-8u231-linux-x64.tar.gz
RUN tar zxvf jdk-8u231-linux-x64.tar.gz -C /usr/local/
ENV JAVA_HOME /usr/local/jdk1.8.0_231
ENV PATH $PATH:$JAVA_HOME/bin
RUN java -version

# 安装node npm
RUN wget http://update.gonsincloud.com/jenkins/node-v16.16.0-linux-x64.tar
RUN tar -xvf node-v16.16.0-linux-x64.tar -C /usr/local/
ENV NPM_HOME /usr/local/node-v16.16.0-linux-x64
ENV PATH $PATH:$NPM_HOME/bin
RUN npm -version

# 安装maven
RUN wget -nc http://update.gonsincloud.com/jenkins/apache-maven-3.6.2-bin.tar.gz
RUN tar zxvf apache-maven-3.6.2-bin.tar.gz -C /usr/local/
RUN cp /usr/local/apache-maven-3.6.2/conf/settings.xml /usr/local/apache-maven-3.6.2/conf/settings.xml.bk
COPY settings.xml /usr/local/apache-maven-3.6.2/conf/settings.xml
ENV MAVEN_HOME /usr/local/apache-maven-3.6.2
ENV PATH $PATH:$MAVEN_HOME/bin
RUN mvn -version

# 安装gradle
RUN wget -nc http://update.gonsincloud.com/jenkins/gradle-6.7.1-bin.zip
RUN unzip -d /usr/local/ gradle-6.7.1-bin.zip
RUN chmod 777 /usr/local/gradle-6.7.1/bin
ENV GRADLE_HOME /usr/local/gradle-6.7.1
ENV PATH $PATH:$GRADLE_HOME/bin
COPY init.gradle /usr/local/android/init.gradle
RUN gradle -version

# 安装安卓SDK
RUN wget -nc http://update.gonsincloud.com/jenkins/commandlinetools-linux-8512546_latest.zip
RUN unzip -d /usr/local/android/sdk/ commandlinetools-linux-8512546_latest.zip
RUN mkdir /usr/local/android/sdk/cmdline-tools/latest
RUN mv /usr/local/android/sdk/cmdline-tools/bin  /usr/local/android/sdk/cmdline-tools/latest/bin
RUN mv /usr/local/android/sdk/cmdline-tools/lib  /usr/local/android/sdk/cmdline-tools/latest/lib
RUN mv /usr/local/android/sdk/cmdline-tools/NOTICE.txt  /usr/local/android/sdk/cmdline-tools/latest/NOTICE.txt
RUN mv /usr/local/android/sdk/cmdline-tools/source.properties  /usr/local/android/sdk/cmdline-tools/latest/source.properties


ENV ANDROID_HOME /usr/local/android/sdk/
ENV PATH $PATH:$ANDROID_HOME/cmdline-tools/latest/bin
RUN sdkmanager --list
RUN sdkmanager --install "platform-tools"
RUN sdkmanager --install "build-tools;28.0.3"
RUN sdkmanager --install "emulator"
RUN sdkmanager --install "tools"
RUN sdkmanager --install "platforms;android-28"
RUN yes | sdkmanager --licenses



#安装apifox
# RUN npm config set registry http://registry.npm.taobao.org
# RUN npm install -g apifox-cli


# 安装jmeter
RUN wget -nc http://update.gonsincloud.com/jenkins/apache-jmeter-5.3.tgz
RUN tar zxvf apache-jmeter-5.3.tgz -C /usr/local/
ENV JMETER_HOME /usr/local/apache-jmeter-5.3
ENV PATH $PATH:$JMETER_HOME/bin
RUN jmeter -v


# 安装python
RUN apt install -y python3
RUN python3 --version

# 安装nvm
RUN apt install git -y
RUN curl -o- http://update.gonsincloud.com/jenkins/install_nvm.sh | bash

# 安装nvm
RUN curl -o- http://update.gonsincloud.com/jenkins/install_nvm.sh | bash
ENV NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node/


# 安装 docker-compose 和 docker
RUN apt-get update
RUN apt-get install -y lsb-release 
RUN apt-get install -y curl
RUN apt install -y software-properties-common
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc http://update.gonsincloud.com/jenkins/gpg
# RUN echo "deb [arch=$(dpkg --print-architecture) \
#   signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
#   https://download.docker.com/linux/debian \
#   $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
# RUN chmod 777 /etc/apt/sources.list.d/docker.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32 871920D1991BC93C 7EA0A9C3F273FCD8
RUN apt-get update
RUN add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal stable"
RUN echo "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal stable" >> /etc/apt/sources.list
RUN apt-get update 
RUN apt-get install -y docker-ce-cli
RUN apt-get install -y docker-compose
RUN docker --version
RUN docker-compose --version


# 安装mysql
RUN apt install mysql-client-8* -y
RUN mysql --version 

# 使用jenkins国内源
# COPY default.json /var/jenkins_home/updates/default.json
RUN mkdir /var/jenkins_home/
COPY hudson.model.UpdateCenter.xml /var/jenkins_home/hudson.model.UpdateCenter.xml
ENV JENKINS_HOME /var/jenkins_home/
ADD jenkins.war /var/jenkins_home/jenkins.war
RUN chmod 777 /var/jenkins_home/jenkins.war
RUN apt-get install xvfb -y
RUN apt-get install ttf-dejavu -y
RUN apt-get install fontconfig -y
CMD ["/root/jenkins/jdk17/bin/java", "-jar", "/var/jenkins_home/jenkins.war", "-Djava.awt.headless=true"]
WORKDIR /var/jenkins_home/


